<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$plugin_name = $_RQ['basicname'] ? $_RQ['basicname'] : '';
if($_RQ['op']=='get'){
	//显示统计数据
		$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		$yesterday = date('d') - 1;
		$yestime = mktime(0,0,0,date('m'),$yesterday,date('Y'));
		$mounthtime =  mktime(0,0,0,date('m'),1,date('Y'));
		$between=array($yestime,$daytime);
		$access=array();
		$access['wechat_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'join_time >'=>$daytime));
		$access['wxapp_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'createtime between'=>$between));
		$access['tui_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'status'=>1,'join_time >'=>$daytime));
		$access['pc_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'join_time >'=>$daytime));
		$access['app_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'join_time >'=>$daytime));
		$access['all_day']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'join_time >'=>$daytime));
		$access['wechat_all']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']));
		$access['wxapp_all']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']));
		$access['tui_all']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'status'=>1));
		$access['pc_all']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']));
		$access['app_all']=pdo_count('jy_scrm_qun_member',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']));
		$access['qun_all']=pdo_count('jy_scrm_qun',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']));
		$access['qun_usernum']=pdo_getsum('jy_scrm_qun',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']),'num');
		//月份
		for($i=0;$i<12;$i++){
				if($i==0){
					$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
					$yueend = time();
					
				}else{
					$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
					$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
				}
				$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']);
				$params['join_time between']=array($yuestart,$yueend);
				$month12[$i] = date('Y-m',strtotime('-'.$i.' month'));
				$accessline[$i]=pdo_count('jy_scrm_qun_member',$params);
				//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
		}
		$accessline=array_reverse($accessline);
		$month12=array_reverse($month12);
		$return['htmls']=array(
				array('type'=>'data','tpltype'=>4,'one_num'=>4,'title'=>'今日/总客户数据指标','datas'=>array(
					array('title'=>'今日新进群人数','num'=>2,'data'=>array($access['wechat_day'],$access['wechat_all']),'datatitle'=>array('今日','总人数')),
					array('title'=>'昨日新进群人数','bgcolor'=>'#009933','num'=>2,'data'=>array($access['wxapp_day'],$access['wxapp_all']),'datatitle'=>array('昨日','总人数')),
					array('title'=>'昨日退群人数','bgcolor'=>'#3366FF','num'=>2,'data'=>array($access['tui_day'],$access['tui_all']),'datatitle'=>array('今日','总人数')),
					array('title'=>'总群数','bgcolor'=>'#FF3300','num'=>2,'data'=>array($access['qun_all'],$access['qun_usernum']),'datatitle'=>array('群数','群人数')),
				)),
				array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度群成员人数','datas'=>array(
					'datas'=>array(
						array('name'=>'群成员人数','value'=>$accessline),
					),
					'xdatas'=>$month12,
				)),
		);
	exi($return);
}